<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>带prop的todo-item组件</title>
</head>

<body>
    <h1>带prop的todo-item组件</h1>
    <div style="color:gray">
        <p>开发使用带prop的todo-item 组件。</p>
    </div>
    <div>
        <a href="/">回目录</a>
    </div>
    <hr>
    <div id="app">
        <ol>
            <todo-item v-for="item in groceryList" v-bind:todo="item" :key="item.id"></todo-item>
        </ol>
    </div>
    <script src="/node_modules/vue/dist/vue.js"></script>
    <script>
        Vue.component("todo-item", {
            props: ["todo"],
            template: "<li>{{ todo.text }}</li>"
        });
        var app = new Vue({
            el: "#app",
            data: {
                groceryList: [{
                        id: 0,
                        text: '蔬菜'
                    },
                    {
                        id: 1,
                        text: '奶酪'
                    },
                    {
                        id: 2,
                        text: '随便其它什么人吃的东西'
                    }
                ]
            }
        });
    </script>
</body>

</html>